package thefirst.LessonBoard.model;

import java.sql.SQLException;
import java.util.List;

import javax.annotation.Resource;


import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import thefirst.member.model.MemberVO;

@Repository
public class LessonBoardDaoImpl implements LessonBoardDao {
	@Resource(name = "sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;

	@Override
	public void writeLessonBoard(LessonBoardVO lessonBoardVO) throws SQLException {
		//System.out.println("writeLessonBoard : "+ lessonBoardVO);
		sqlSessionTemplate.insert("lessonBoard.writeLesson",lessonBoardVO);
		
	}

	@Override
	public List<LessonBoardVO> getLessonBoardList(String pageNo)
			throws SQLException {
		return sqlSessionTemplate.selectList("lessonBoard.getLessonBoardList",pageNo);
	}

	@Override
	public int totalLessonContent() throws SQLException {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectOne("lessonBoard.totalLessonContent");
	}

	@Override
	public LessonBoardVO showLessonBoardInfoNoHits(LessonBoardVO lvo) throws SQLException {
		LessonBoardVO lbvo=sqlSessionTemplate.selectOne("lessonBoard.showLessonInfoNoHits",lvo);
		return lbvo;
	}

	@Override
	public int updateHits(LessonBoardVO lvo) throws SQLException {
		//System.out.println("updateHits : "+ lvo.getLessonno());
		return sqlSessionTemplate.update("lessonBoard.updateHits",lvo.getLessonno());
	}

	@Override
	public void deleteLessonContent(LessonBoardVO lvo) throws SQLException {
		sqlSessionTemplate.delete("lessonBoard.deleteLessonContent",lvo);
		
	}

	@Override
	public int updateBoardContent(LessonBoardVO lvo)
			throws SQLException {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.update("lessonBoard.updateLessonContent",lvo);
	}

}
